package com.ruoyi.web.controller.enterprise;


import com.hxzy.enterprise.entity.TtVendorContract;
import com.hxzy.enterprise.service.TtVendorContractService;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.DataSourceType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author baiyu
 * @since 2023-06-26
 */
@DataSource(DataSourceType.ENTERPRISE)
@RestController
@RequestMapping("/tt-vendor-contract")
public class TtVendorContractController {
    @Autowired
    private TtVendorContractService ttVendorContractService;

    @RequestMapping("/allTtv")
    public AjaxResult getTtVendorContract() {
        List<TtVendorContract> ttVendorContract = ttVendorContractService.getTtVendorContract();
        if (ttVendorContract != null) {
            return AjaxResult.success(ttVendorContract);
        }
        return AjaxResult.error();
    }

    @RequestMapping("/insterTtx")
    public AjaxResult insterTtVendorContract(@RequestBody TtVendorContract ttVendorContract) {
        TtVendorContract ttVendorContract1 = ttVendorContractService.insterTtVendorContract(ttVendorContract);
        if (ttVendorContract1 != null) {
            return AjaxResult.success(ttVendorContract1);
        }
        return AjaxResult.error();
    }

    @PutMapping("/UpdataTtx")
    public AjaxResult UpdataTtVendorContract(@RequestBody TtVendorContract ttVendorContract) {
        int i = ttVendorContractService.updataTtVendorContract(ttVendorContract);
        if (i > 0) {
            return AjaxResult.success(ttVendorContract);
        }
        return AjaxResult.error();
    }

    @RequestMapping("/selectbyid")
    public AjaxResult selectbyidTtVendorContract(@RequestParam String id) {
        TtVendorContract ttVendorContract1 = ttVendorContractService.getTtVendorContract1(id);
        if (ttVendorContract1 != null) {
            return AjaxResult.success(ttVendorContract1);
        }
        return AjaxResult.error();
    }

    @DeleteMapping("/deletetbyid")
    public AjaxResult deletetbyidTtVendorContract(@RequestParam String id) {

        int i = ttVendorContractService.deletaTtVendorContract(id);
        if (i > 0) {
            return AjaxResult.success("删除成功");
        }
        return AjaxResult.error();
    }
//    @RequestMapping("/selectlike")
//    public AjaxResult selectlikeTtVendorContract(@RequestBody TtVendorContract ttVendorContract){
//        List<TtVendorContract> ttVendorContract1 = ttVendorContractService.getTtVendorContract(ttVendorContract);
//        if(ttVendorContract1!=null){
//            return AjaxResult.success(ttVendorContract);
//        }
//        return AjaxResult.error();
//    }
}
